import { Link, Navigate } from "react-router-dom"
import { Button } from "@/components/ui/button"
import { AuthLayout } from "@/layouts/AuthLayout"
import { useAuth } from "@/context/AuthContext"
import Loading from "./pages/misc/Loading";

function App() {
  const { isAuthenticated, isLoading } = useAuth();

  
  if (isLoading) {
    return <Loading />;
  }

  // 已认证用户重定向到电商网站主页
  if (isAuthenticated) {
    return <Navigate to="/mall" replace />;
  }
  
  // 未认证用户，显示登录/注册引导页面
  return (
    <AuthLayout>
    
      <div className="flex flex-col items-center justify-center gap-6">
        <p className="text-xl text-gray-300">欢迎来到Nekonomics电商平台</p>
        
        <div className="flex gap-4">
          <Link to="/auth/login">
            <Button variant="default">登录</Button>
          </Link>
          <Link to="/auth/register">
            <Button variant="outline">注册</Button>
          </Link>
        </div>
      </div>
    </AuthLayout>
  )
}

export default App
